Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming
Raising and handling error conditions
Methods do not support the
RETURNstatement with theERRORoption. The compiler generates an error if it encounters this statement in a constructor, destructor, or method in a class file. In addition, the compiler generates an error if theRETURNERRORoption of theONERRORphrase is used within a class.In a class or method, you must provide an application-defined mechanism for returning status information to callers. There are several approaches that you might use to have an invoked method inform its caller that it has encountered an error. One mechanism for returning this status information is for the invoked method to set a status output parameter. Alternatively, the invoked method can set a public status data member. In either case, the caller of the method needs to evaluate this status information in order to detect if the method has executed successfully. However, statements within a method, constructor, or destructor can still fail and raise an error condition, so you must still code for them and handle these conditions appropriately.
Comparison with procedure-based programming
The 4GL supports a mechanism for procedures to raise an error condition in the caller. There is no parallel mechanism for a user-defined function or a class-based method. Procedures can use the
RETURN ERRORstatement to cause anERRORcondition to be raised in the calling block. This causes theERRORcondition to be raised for theRUNstatement that invoked the procedure. An application can use theERRORoption of theRETURNstatement only in a procedure or a database trigger block. An application cannot use theERRORcondition from a user-defined function or method.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |